﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using QLST_BUS;

namespace QLST_CoopMart_GoVap
{
    public partial class frmThem_CapNhatHangHoacs : Form
    {
        //Nhà cung câp
        //DataProvider dap = new DataProvider();
        private BindingSource bdSource = new BindingSource();


        public frmThem_CapNhatHangHoacs()
        {
            InitializeComponent();
        }

        private void txtPath_MouseClick(object sender, MouseEventArgs e)
        {
            

        }
        /// <summary>
        /// Hiển thị hình ảnh
        /// </summary>
        /// <param name="path"></param>
        public void ShowImage(string path)
        {
            txtPath.Text = path;
            pbImge.ImageLocation = path;
        }
        private void btnPath_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = "Image files|*.jpg|All files (*.*)|*.*";
            dialog.InitialDirectory = Application.StartupPath;
            dialog.Title = "Vui lòng chọn hình theo đúng định dạng";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                ShowImage(dialog.FileName);
            }          
        }

        private void pbImge_MouseEnter(object sender, EventArgs e)
        {

        }

        private void txtPath_Enter(object sender, EventArgs e)
        {
           
            //C:\Users\PeterNguyen\Pictures\anhtrang\wallpaper-1.jpg
        }

        private void txtPath_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                if (txtPath.Text.Trim() != "")
                {
                    if (System.IO.File.Exists(txtPath.Text))
                    {
                        txtPath.BackColor = Color.White;
                        ShowImage(txtPath.Text);
                    }
                    else
                    {
                        txtPath.BackColor = Color.Red;
                        MessageBox.Show("Đường dẫn tới hình ảnh không hợp lệ", "Lỗi sử dụng", MessageBoxButtons.OK,
                            MessageBoxIcon.Error);

                        return;
                    }
                }
            }
        }

        /// <summary>
        /// Lấy danh sách nhà cung cấp
        /// </summary>
        public void GetNhaCC()
        {
            //bdSource.DataSource = dap.ExcuteProcedureGetTable("st_GetNCC", null);
            //dvNagNCC.BindingSource = bdSource;
            //dgvNCC.DataSource = bdSource;
            //st_GetNCC
        }

        private void frmThem_CapNhatHangHoacs_Load(object sender, EventArgs e)
        {
            GetNhaCC();
        }
    }
}
